package com.shenda.device.enums;

/**
 * 采集模式
 * 
 * @author lifeng
 * @date 2020年5月16日 上午10:07:44
 */
public enum Cjms {

	Acc("01", "Acc", 6), Gyr("02", "Gyr", 6), AccGyr("03", "Acc+Gyr", 12);

	private String cmd;
	private String show;
	private Integer record;

	private Cjms(String cmd, String show, Integer record) {
		this.cmd = cmd;
		this.show = show;
		this.record = record;
	}

	public String getCmd() {
		return cmd;
	}

	public void setCmd(String cmd) {
		this.cmd = cmd;
	}

	public String getShow() {
		return show;
	}

	public void setShow(String show) {
		this.show = show;
	}

	public Integer getRecord() {
		return record;
	}

	public void setRecord(Integer record) {
		this.record = record;
	}

	/**
	 * 命令行转换为显示模式
	 * 
	 * @return
	 */
	public static Cjms byCmd(String cmd) {
		for (Cjms cjms : Cjms.values()) {
			if (cjms.cmd.equals(cmd)) {
				return cjms;
			}
		}
		throw new RuntimeException("采集模式转换错误！：" + cmd);
	}

	/**
	 * 命令行转换为显示模式
	 * 
	 * @return
	 */
	public static String cmd2show(String cmd) {
		for (Cjms cjms : Cjms.values()) {
			if (cjms.cmd.equals(cmd)) {
				return cjms.show;
			}
		}
		throw new RuntimeException("采集模式转换错误！：" + cmd);
	}

	/**
	 * 命令行转换为模式的长度
	 * 
	 * @return
	 */
	public static Integer cmd2record(String cmd) {
		for (Cjms cjms : Cjms.values()) {
			if (cjms.cmd.equals(cmd)) {
				return cjms.record;
			}
		}
		throw new RuntimeException("采集模式转换错误！：" + cmd);
	}
}